package com.bruce.demo2.patterns.demo3.behavioral.demo15.command;

import java.util.Map;
import java.util.Set;

/**
 * @PROJECT_NAME: design_patterns
 * @DESCRIPTION: 具体实现类 具体命令
 * @AUTHOR: CNBruceLee
 * @DATE: 2021/8/31 7:21
 */
public class OrderCommand implements Command {

    //持有接收者对象
    private SeniorChef receiver;
    //持有订单对象
    private Order order;

    public OrderCommand(SeniorChef receiver, Order order) {
        this.receiver = receiver;
        this.order = order;
    }

    public void execute() {
        System.out.println(order.getDiningTable() + "桌订单：");

        //获取订单 然后制作
        Map<String, Integer> foodDir = order.getFoodDir();

        Set<String> keys = foodDir.keySet();
        for (String footName : keys) {
            receiver.makeFood(footName, foodDir.get(footName));
        }
        System.out.println(order.getDiningTable() + "桌的饭准备完毕");
    }
}
